// ignore_for_file: non_constant_identifier_names
import 'package:bt_dsp_88/commont/chart_view.dart';
import 'package:flutter/material.dart';

import '../../model/model.dart';
import '../../tool/assets.dart';

class ChartBG extends StatefulWidget {
  ChannelModel? ch;
  ChartBG({super.key, required this.ch});
  @override
  State<ChartBG> createState() => _ChartBGState();
}

class _ChartBGState extends State<ChartBG> {
  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (BuildContext context, BoxConstraints constrains) {
        ///计算绘图的真实宽度，高度
        var size = Size(constrains.maxWidth, constrains.maxHeight);
        var padding = const EdgeInsets.only(left: 20, right: 5, top: 5, bottom: 20);

        return Stack(
          children: [
            Container(
              alignment: Alignment.center,
              padding: const EdgeInsets.only(left: 20, right: 10),
              child: Image.asset(
                assets.bg_chart,
                fit: BoxFit.cover,
                alignment: Alignment.center,
              ),
            ),
            ChartView(ch: widget.ch, size: size, padding: padding, minY: -12, maxY: 12),
          ],
        );
      },
    );
  }
}
